package com.geen.tuoke.base

import androidx.databinding.ViewDataBinding
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder


abstract class BaseAdapter<T, K : ViewDataBinding> constructor(
    layoutResId: Int,
    data: MutableList<T>? = null
) : BaseQuickAdapter<T, BaseDataBindingHolder<K>>(layoutResId, data) {


    override fun convert(holder: BaseDataBindingHolder<K>, item: T) {
        holder.dataBinding?.let {
            onUpdate(it, item, holder.adapterPosition)
            it.executePendingBindings()
        }
    }

    abstract fun onUpdate(binding: K, item: T, position: Int)
}

